package org.lili.semanticmodel;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author lili
 * @description 图形
 * @create 2018-04-22 下午3:24
 * @since
 **/
public class Graph {

    /**
     * 图形的组成边集合
     */
    private List<Edge> edges;

    /**
     * 图形的点集合
     */
    private Set<Vertex> vertices;

    public Graph() {
        edges = new ArrayList<>();
        vertices = new TreeSet<>();
    }

    public void addEdge(Edge edge) {
        getEdges().add(edge);
    }

    public void addVertice(Vertex v) {
        getVertices().add(v);
    }

    /**
     * 打印图形
     * @param g
     */
    public static void printGraph(Graph g) {
        System.out.println("Vertices...");
        for (Vertex v : g.getVertices()) {
            System.out.print(v.getLabel() + " ");
        }
        System.out.println("");
        System.out.println("Edges...");
        for (Edge e : g.getEdges()) {
            System.out.println(e);
        }
    }

    public List<Edge> getEdges() {
        return edges;
    }

    public void setEdges(List<Edge> edges) {
        this.edges = edges;
    }

    public Set<Vertex> getVertices() {
        return vertices;
    }

    public void setVertices(Set<Vertex> vertices) {
        this.vertices = vertices;
    }
}
